package com.org.csu.converter;

import com.org.csu.dto.KeywordDTO;
import com.org.csu.entity.Keyword;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author YigongLily
 * @version V1.0
 * Copyright (c) 2024, t8669@qq.com All Rights Reserved.
 * @ProjectName:e-commerce-back
 * @Title: KeywordConverter
 * @Package com.org.csu.converter
 * @Description: kwconvert
 * @date 2024/12/15 12:02
 */

public class KeywordConverter {
    public static KeywordDTO convertKeyword(Keyword keyword) {
        KeywordDTO keywordDTO = new KeywordDTO();
        keywordDTO.setFlow(keyword.getFlow());
        keywordDTO.setHot(keyword.getHot());
        keywordDTO.setValue(keyword.getValue());
        keywordDTO.setRate(keyword.getRate());
        keywordDTO.setUrl(keyword.getUrl());
        keywordDTO.setWord(keyword.getWord());
        keywordDTO.setWordId(keyword.getWordId());
        keywordDTO.setDate(keyword.getDate());
        return keywordDTO;
    }

    public static List<KeywordDTO> convertKeywordList(List<Keyword> keywordList) {
        return keywordList.stream()  // 将List转换为Stream
                .map(KeywordConverter::convertKeyword)  // 应用convertKeyword方法到Stream的每个元素
                .collect(Collectors.toList());  // 将结果收集到一个新的List中
    }


}